﻿@model VisaApp.Models.SendMailModelPri
@{  AjaxOptions ajaxOpts = new AjaxOptions
    {
        HttpMethod = "post",
        OnComplete = "completedAjaxRequestFromCauHoi",
        OnBegin = "show_Loading",
    };
}

<script type="text/javascript">

    function completedAjaxRequestFromCauHoi(obj) {

        $('#box-busy').fadeOut('medium', function () {
            $('.black_overlay').css('display', 'none');
        });

        var returnObj = eval('(' + obj.responseText + ')');

        if (returnObj.Status == "success") {
            makeSuccessHighlightFromCauHoi("Gởi Email thành công");
        } else {
            makeErrorHighlightFromCauHoi(returnObj.Message);
        }

        return false;
    }

    function makeErrorHighlightFromCauHoi(messageStr) {
        var $highlight = $("<div style='padding: 0.7em; margin-bottom:5px; width: inherit;'><p><span class='' style='float: left;'></span><strong>Lỗi: </strong>" + messageStr + "</p></div>");
        $highlight.addClass("ui-state-highlight ui-corner-all");
        $highlight.prependTo(".warning-area-cauhoi");
        $highlight.delay(4000).fadeOut(500);

    }

    function makeSuccessHighlightFromCauHoi(messageStr) {
        var $highlight = $("<div style='padding:0.7em; margin-bottom:5px; width: inherit;'><p><span class='' style='float: left;'></span><strong>Thành công: </strong>" + messageStr + "</p></div>");
        $highlight.addClass("ui-state-highlight ui-corner-all");
        $("#tabs-1").html("");
        $highlight.prependTo("#tabs-1");
    }

    $(document).ready(function () {
        $(".rich-text").cleditor({ width: 520, height: 550, useCSS: true });
        var ids = $("#listHinhThuc").val();
        $("#EmailSendId").val(ids);
    });

    function onlistHinhThuc() {
        var ids = $("#listHinhThuc").val();
        $("#EmailSendId").val(ids);
    }

</script>
@using (Ajax.BeginForm("ListEmailSendAds", "Quantri", null, ajaxOpts, new { enctype = "multipart/form-data", name = "frm_register-visa", id = "frm_register-visa" }))
{
     <div class="section-header">
        <div class="options">
            <button type="submit" name="save" value="save" class="t-button">
                Gởi Email</button>
        </div>
    </div>
    <div id="tabasAddCategory">
        <ul>
            <li><a href="#tabs-1">Thông tin</a></li>
        </ul>
        <div id="tabs-1">
            <table>
                <tr>
                    <td class="adminTitle">
                        Chọn danh sách cần gởi :
                    </td>
                    <td class="adminData">
                       @for (var i = 0; i < Model.ListModdel.Count(); i++)
                       {
                          <div style="float:left; padding:7px">
                            @Html.HiddenFor(it => it.ListModdel[i].Id)
                            @Html.TextBoxFor(it => it.ListModdel[i].Name, new { disabled = "disabled" })
                            @Html.CheckBoxFor(it => it.ListModdel[i].Checkbox)
                          </div>
                       }
                    </td>
                </tr>
                <tr>
                    <td class="adminTitle">
                        Chọn email trả lời:
                    </td>
                    <td class="adminData">
                       @Html.HiddenFor(model => model.EmailSendId, new { id = "EmailSendId" })
                       @Html.DropDownList("listEmaiilCode", null, new { @class = "DropDownListPostNews", @id = "listHinhThuc", @onchange = "onlistHinhThuc()" })
                    </td>
                </tr>
                 <tr>
                    <td class="adminTitle">
                        Tiêu đề email:
                    </td>
                    <td class="adminData">
                      @Html.TextBoxFor(model => model.Tieude, new { @style = "width:300px" })
                    </td>
                </tr>
                <tr>
                    <td class="adminTitle">
                       Nội dung email:
                    </td>
                    <td class="adminData">
                      @Html.TextAreaFor(model => model.Noidung, new { name = "NoiDung", @class = "txt_NoiDung rich-text validate[required]", style = "width: 98%; height:148px;" })
                    </td>
                </tr>
            </table>
        </div>
    </div>
}